#include "stdafx.h"
#include "GameRoom.h"
#include "GameItem.h"
#include "HBoxPlacerRule.h"
#include "HBoxes.h"

namespace BombBox
{
	GameRoom::GameRoom(void)
		: vRoomScale(1,1,1)
		, vRoomTrans(0,0,0)
		, vRoomRotate(0,0,0)
	{
		sRoomFile = "media/Plane.X";
		sRoomConfig = "";
		m_pController = NULL;
		m_bRoomStatus = RS_NULL;
	}

	GameRoom::~GameRoom(void)
	{
	}

	void GameRoom::setRoomFile( irr::core::stringc sFile )
	{
		sRoomFile = sFile;
	}

	void GameRoom::clearLogicAndRender( void )
	{
		if( m_pController )
			m_pController->uninitialze();

		int nCount = vItems.size();
		for( int i=0; i<nCount; ++i )
		{
			delete vItems[i];
		}
		vItems.clear();
	}

	void GameRoom::registerBox( BoxItem* pBox )
	{
		vItems.push_back(pBox);
	}

	void GameRoom::setActive( bool bActive )
	{
	}

	irr::core::stringc GameRoom::getItemMesh( void )
	{
		return sRoomFile;
	}

	void GameRoom::setRoomStatus( RoomStatus nStatus, bool clear )
	{
		m_bRoomStatus = nStatus;

		//if( clear )
		//	s_pBoxPlacerRuler->clear(this);
	}

	bool GameRoom::isRoomStatus( RoomStatus nStatus )
	{
		return m_bRoomStatus == nStatus;
	}

	const irr::core::vector3df& GameRoom::getCameraPos( void )
	{
		return vCamPos;
	}

	const irr::core::vector3df& GameRoom::getCameraTarget( void )
	{
		return vCamTarget;
	}

	bool GameRoom::enableLight( void )
	{
		return false;
	}

	void GameRoom::doRoatate( GUI::s16 delta )
	{
		//SceneItem* item = dynamic_cast<SceneItem*>(pItem->getItemController());

		//if(item)
		//{
		//	irr::f32 vCurRotY;
		//	if( delta>0 )
		//	{
		//		vCurRotY = item->getRotation().Y + 10.0f;
		//	}
		//	else
		//	{
		//		vCurRotY = item->getRotation().Y - 10.0f;
		//	}

		//	if( vCurRotY > 360.0f )
		//	{
		//		vCurRotY -= 360.0f;
		//	}
		//	if( vCurRotY < -360.0f )
		//	{
		//		vCurRotY += 360.0f;
		//	}
		//	irr::core::vector3df vCurRot = irr::core::vector3df(item->getRotation().X, vCurRotY, item->getRotation().Z);
		//	item->setRotation(vCurRot);
		//}
	}



	const irr::core::vector3df& GameRoom::getRoomScale( void )
	{
		return vRoomScale;
	}

	const irr::core::vector3df& GameRoom::getRoomTrans( void )
	{
		return vRoomTrans;
	}
	
	const irr::core::vector3df& GameRoom::getRoomRotate( void )
	{
		return vRoomRotate;
	}
}